It is said that David was a man after God's own heart. However, (in 1st Kings 2: 5-9) David instructed Soloman to get revenge for him on Joab and Shimei. Joab killed both Abner and Amasa in peacetime. Granted, Joab could be considered a threat to Solomon and indeed later tried to dethrone Him. However, there is no indication that Shimei was in a position to be a threat as Joab could be. David wanted Shimei killed for cursing David while David was fleeing from Absalom. David swore to Shimei that David would not have him killed. So he instructed Solomon to do it. How could a man after God's own heart have malice in his heart when he is dying?